package com.damage.common.entity;

import com.damage.common.dto.PurchasePlanMaker;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;

import java.beans.Transient;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class PurchasePlan implements Serializable {

    private Integer id;                         //采购计划编号
    private String processInstanceId;           //对应流程实例的编号
    private String planner;                     //采购计划制定人
    private Double totalPrice;                  //采购计划的总价格
    private String reason;                      //制定采购计划的原因
    private String auditor;                     //采购计划审核人
    private String remark;                      //审核人员对计划的评论
    private Integer state;                      //采购计划状态(0未审核，1审核通过，2审核不通过，3已生成订单等)
    private Integer isObsolete;                 //是否过时(0未过时，1已过时)
    private Timestamp modifyTime;               //修改时间
    private Timestamp createTime;               //创建时间
    private List<PurchasePlanDetail> details;   //采购计划详细

    public PurchasePlan(PurchasePlanMaker purchasePlanMaker) {
        this.planner = purchasePlanMaker.getPlanner();
        this.totalPrice = purchasePlanMaker.getTotalPrice();
        this.reason = purchasePlanMaker.getReason();
        this.details = purchasePlanMaker.getDetails();
    }

    /**
     * 临时属性
     */
    private Task task;  //流程任务

    private Map<String, Object> variables;  //流程变量

    private ProcessInstance processInstance;    //运行中的流程实例

    private HistoricProcessInstance historicProcessInstance;    //历史的流程实例

    private ProcessDefinition processDefinition;    //流程定义

    @Transient
    public Task getTask() {
        return task;
    }

    @Transient
    public Map<String, Object> getVariables() {
        return variables;
    }

    @Transient
    public ProcessInstance getProcessInstance() {
        return processInstance;
    }

    @Transient
    public HistoricProcessInstance getHistoricProcessInstance() {
        return historicProcessInstance;
    }

    @Transient
    public ProcessDefinition getProcessDefinition() {
        return processDefinition;
    }
}
